import Cookies from 'js-cookie'

const state = {
  size: Cookies.get('size') || 'small',
  theme: Cookies.get('theme') || '#409EFF'
}

const mutations = {
  SET_SIZE: (state, size) => {
    state.size = size
    Cookies.set('size', size)
  },
  SET_THEME: (state, theme) => {
    state.theme = theme
    Cookies.set('theme', theme)
  }
}

const actions = {
  setSize({ commit }, size) {
    commit('SET_SIZE', size)
  },
  setTheme({ commit }, theme) {
    commit('SET_THEME', theme)
  }
}

export default {
  state,
  mutations,
  actions
}
